<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ include file="/common/base.jsp"%>
<%
 //所在乡镇行政区域编码
 String town=(String)session.getAttribute("agencode");
Institution inst=new Institution();
inst.setAgencode(town);
inst.loadDB();
town=inst.getArea().getAreacode();
 AreaDao areaDao =new AreaDao();
 //根据乡镇编码获取所有村
 List<Area> areaVillage=areaDao.findChildArea(town, 3);
 List<Area> areaGroup=areaDao.findChildArea(town,4);
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
	content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
<meta name="renderer" content="webkit">
<link rel="stylesheet" type="text/css" href="css/styles.css">
<link rel="stylesheet" type="text/css" href="css/admin.css">
<script type="text/javascript" src="js/jquery-1.4.4.min.js"></script>
<script type="text/javascript" src="js/admin.js"></script>
<!-- 引入第三方日期JS组件 -->
<script type="text/javascript" src="third/laydate/laydate.js"></script>
<script type="text/javascript">
	$(document).ready(function() {
		//重新绑定表单提交
		$("#add_btn").bind("click", function() {
			$('form').submit();
		});
	});
	//选择不同的村组
	function chooseGroup(){
		var val=$("#village").val();
		$.ajax({
			   type: "POST",
			   url: "<%=path%>/system/AreaServlet?m=groupList",
			   data: {"villageID":val},
			   dataType:"json",
			   success: function(data){
				 $("#group").empty();
			     $.each(data,function(i,val){
			    	 $("#group").append("<option value='"+val.areacode+"'>"+val.areaname+"</option>");
			     });
			   }
			});
	}
	
	function cascade(){
		var town=$("#village").find("option:selected").attr("data");
		var village=$("#village").find("option:selected").text();
		var group=$("#group").find("option:selected").text();
		
	}
</script>
</head>
<body>
	<div class="panel admin-panel">
		<div class="panel-head" id="add">
			<strong><span class="icon-pencil-square-o"></span>增加家庭档案</strong>
		</div>
		<div class="body-content">
			<form id="form-add" method="post" 
				action="<%=path%>/system/FamilyServlet?m=add">
				<input type="hidden" name="town" value="<%=town%>"/>
				<div class="form-x">
				<div class="form-group">
					<div class="label">
						<label>所在村：</label>
					</div>
					<div class="field">
						<select id="village" name="village" class="input w50"
							onchange="chooseGroup();">
							<% for(Area m:areaVillage) {%>				
							<option data="<%=m.getParent().getAreaname() %>" value="<%=m.getAreacode()%>"><%=m.getAreaname() %></option>
							<% } %>
						</select>
						<div class="tips"></div>
					</div>
				</div>
					<div class="form-group">
						<div class="label">
							<label>所在组：</label>
						</div>
						<div class="field">
							<select id="group" name="group" class="input w50" >
								<% for(Area m:areaGroup) {%>				
							<option  value="<%=m.getAreacode()%>"><%=m.getAreaname() %></option>
							<% } %>
							</select>
							<div class="tips"></div>
						</div>
					</div>
						<div class="form-group">
						<div class="label">
							<label>户属性：</label>
						</div>
						<div class="field">
							<select id="housePro" name="housePro" class="input w50">
								<option value="1">一般户</option>
								<option value="2">五保户</option>
								<option value="3">军烈属</option>
								<option value="9">其他</option>
							</select>
							<div class="tips"></div>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label>户主姓名：</label>
						</div>
						<div class="field">
							<input type="text" onblur="cascade();" id="persname" name="persname" value="钟海清" data-validate="chinese:姓名必须为中文" class="input w50"/>
							<div class="tips"></div>
						</div>
					</div>
						<div class="form-group">
						<div class="label">
							<label>身份证号：</label>
						</div>
						<div class="field">
							<input type="text" id="cardID" name="cardID"  class="input w50"/>
							<div class="tips"></div>
						</div>
					</div>
						<div class="form-group">
						<div class="label">
							<label>出生年月：</label>
						</div>
						<div class="field">
							<input type="text" id="birthday" name="birthday"  class="input w50"/>
							<div class="tips"></div>
						</div>
					</div>
					
					<div class="form-group">
						<div class="label">
							<label>性别：</label>
						</div>
						<div class="field">
							<select id="sex" name="sex" class="input w50">
								<option value="1">男</option>
								<option value="2">女</option>
							</select>
							<div class="tips"></div>
						</div>
					</div>
						<div class="form-group">
						<div class="label">
							<label>人员属性：</label>
						</div>
						<div class="field">
							<select id="persPro" name="persPro" class="input w50">
								<option value="1">一般户</option>
								<option value="2">民政救助对象</option>
							</select>
							<div class="tips"></div>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label>是否农村户口：</label>
						</div>
						<div class="field">
							<select id="isRural" name="isRural" class="input w50">
								<option value="1">是</option>
								<option value="0">否</option>
							</select>
							<div class="tips"></div>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label>职业：</label>
						</div>
						<div class="field">
							<select id="occupation" name="occupation" class="input w50">
								<option value="1">农民</option>
								<option value="2">工人</option>
								<option value="3">学生</option>
								<option value="9">其他</option>
							</select>
							<div class="tips"></div>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label>工作单位：</label>
						</div>
						<div class="field">
							<input type="text" id="workUnit" name="workUnit" data-validate="required:工作单位不能为空" class="input w50">	
							<div class="tips"></div>
						</div>
					</div>
					<div class="form-group">
						<div class="label">
							<label>常住地址：</label>
						</div>
						<div class="field">
							<input type="text" id="liveAddress" name="liveAddress" data-validate="required:常住地址不能为空" class="input w50">	
							<div class="tips"></div>
						</div>
					</div>
						<div class="form-group">
						<div class="label">
							<label>联系电话：</label>
						</div>
						<div class="field">
							<input type="text" id="telephone" name="telephone" data-validate="required:电话号码格式错误" class="input w50">	
							<div class="tips"></div>
						</div>
					</div>
					
					<div class="form-group">
						<div class="label">
							<label></label>
						</div>
						<div class="field">
							<button id="add_btn" class="button bg-main icon-check-square-o"
								type="button">提交</button>
						</div>
					</div>
					</div>
			</form>
		</div>
	</div>
<!--渲染JS日期组件 -->
<script type="text/javascript">
 laydate.render({
  elem: '#birthday'
});
</script>
</body>
</html>
